<template>
  <div class="container">
      <h2>{{detailMsg.title}}</h2>
      <p>
          <Row class="marginT20">
            <i-col span='4' offset='7'><span>来源：{{detailMsg.isource}}</span></i-col>
            <i-col span='4'>{{detailMsg.createDate}}</i-col>
            <i-col span='2' offset='5'>
                <span @click="collect"><img :src="collectImg" alt="" style="vertical-align:top;"><span style="display:inline-block;font-size:17px;color:#00A573;margin-top:5px">{{collectOrnot}}</span></span>
            </i-col>
        </Row>
      </p>
      <div class="img-details marginT20">
          <img :src="detailMsg.cover" alt="" width="760px" height="400px">
      </div>
      <div class="details-msg">
          {{detailMsg.content}}
          
        
      </div>
  </div>
</template>

<script>
// import banner from '@/assets/images/banner.png'
import collectImg from '@/assets/images/collect.png'
export default {
    data(){
        return{
            collectImg:collectImg,
            detailMsg:{
                author: "",
                content: "&nbsp;",
                cover: "http://szxgood.qicp.vip/group1/M00/00/09/rBEcgV6r6QOAMQhXAAA1LOiNSlY321.jpg",
                createDate: 1588324615812,
                id: 151,
                isource: "是",
                newsType: 0,
                title: "市政策"
            },
            collectOrnot:''
            
        }
    },
    mounted(){
        this.infoDetail()
    },
    methods:{
        infoDetail(){
            console.log(123)
             this.$axios('getInfopostInfo',this.$route.query.infoId+'?userPhone='+this.$token.getUUID(),{}).then(res=>{
                console.log(res)
                this.collectOrnot = res.data.collected ? '取消收藏':'收藏'
                this.detailMsg.author=res.data.result.author
                this.detailMsg.content=res.data.result.content
                this.detailMsg.cover=res.data.result.cover
                this.detailMsg.createDate=res.data.result.createDate
                this.detailMsg.id=res.data.result.id
                this.detailMsg.isource=res.data.result.isource
                this.detailMsg.newsType=res.data.result.newsType
                this.detailMsg.title=res.data.result.title
            })
        },
        collect(){
            this.collectOrnot == '收藏' ?this.collectInfo() : this.infoCancelCollect()
            // this.collectInfo()
        },
        collectInfo(){
             this.$axios('getInfopostCollectInfo',this.$route.query.infoId+'?userPhone='+this.$token.getUUID(),{}).then(res=>{
                console.log(res)
                if(res.code==200){
                    this.collectOrnot='取消收藏'
                }                
            })
        },
        infoCancelCollect(){
             this.$axios('getInfodeleteCollectInfo',this.$route.query.infoId+'?userPhone='+this.$token.getUUID(),{}).then(res=>{
                console.log(res)
                if(res.code==200){
                    this.collectOrnot='收藏'
                }  
                
            })
        },





    }
}
</script>

<style scoped>
h2{
    text-align: center;
}
.img-details{
    text-align: center;
}
.details-msg{
    width: 1100px;
    margin: 0 auto;
    margin-top: 30px;
}
</style>